(function () {
    "use strict";

    var persons = [
        {
            firstName: 'Ivan',
            lastName: 'Petroff',
            age: 33
        },

        {
            firstName: 'Peter',
            lastName: 'Ivanoff',
            age: 22
        },

        {
            firstName: 'Maria',
            lastName: 'Harizanova',
            age: 21
        },

        {
            firstName: 'Yoana',
            lastName: 'Malinova',
            age: 21
        }
    ];

    function groupByValueInProperty(array, value) {
        var result = [];

        for (var i = 0; i < array.length; i++)
        {
            if (array[i].firstName === value)
            {
                result.push(array[i]);
            }
            else if (array[i].lastName === value)
            {
                result.push(array[i]);
            }
            else if (array[i].age === value)
            {
                result.push(array[i]);
            }
        }

        return result;
    }

    console.log(groupByValueInProperty(persons, 21));
}());